package com.kly.user.config;


import io.rong.models.Result;
import lombok.extern.slf4j.Slf4j;

/**
 * 融云服务调用类
 */
@Slf4j
public class RCInvokeHelper {

    public static <T extends Result> T getData(RCCallBack<T> action) {

        try {
            Result result = action.doInvoker();
            if (result.getCode().equals(200)) {
                return (T) result;
            } else {
                log.error("invoke rongCloud server exception,resultCode={},errorMessage={}", result.getCode(), result.getErrorMessage());
                return (T) result;
            }
        } catch (Exception e) {
            log.error("invoke rongCloud server error：" + e.getMessage(), e);
//            throw new ApplicationException(RestCodeEnum.RC_CONFIG_ERROR);

            return null;
        }
    }
}
